package ThreadCommunicate;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

@Slf4j(topic = "c.TestPark")
public class TestPark {
    public static void main(String[] args) throws InterruptedException {
        test();


    }

    public static void test() throws InterruptedException {
        Thread t1 = new Thread(()->{
            log.debug("park......");
            LockSupport.park();


            log.debug("unpark......");
            Thread.currentThread().interrupt();
            log.debug("Thread.currentThread().isInterrupted():"+Thread.currentThread().isInterrupted());

            //打断标记为true时无法再park,可以用interrupted清除打断标记
            LockSupport.park();
        },"t1");
        t1.start();

        Thread.sleep(2000);
        t1.interrupt();
    }
}


